package service;

import pojo.account.Manager;
import pojo.account.Reader;

public class LoginService {
    /**
     * 该方法进行登录验证
     * @param id 用户id
     * @param password 密码
     * @param identity 身份
     * @return boolean
     */
    public boolean login(String id, String password, String identity) {
        boolean isRight = false;
        AccountService service = new AccountService();
        if (identity.equals("reader")) {
            Reader reader = service.getReader(id);
            if (password.equals(reader.getPassword()))
                isRight = true;
        } else if (identity.equals("manager")) {
            Manager manager = service.getManager(id);
            if (password.equals(manager.getPassword()))
                isRight = true;
        }
        return isRight;
    }
}
